{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "fa9ffb09-e121-4dc3-b4ce-2f49ffc79b8e",
   "metadata": {},
   "source": [
    "# Horizontal Bar Chart\n",
    "\n",
    "A horizontal bar chart for comparing category values along the y-axis. This example uses the `penguins` dataset to show average body mass per species."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bf923874-3780-46e6-b71a-c66cd6edd12e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas  # noqa\n",
    "\n",
    "df = hvplot.sampledata.penguins('pandas')\n",
    "grouped = df.groupby('species', observed=True)['body_mass_g'].mean()\n",
    "\n",
    "grouped.hvplot.barh(\n",
    "    x='species',\n",
    "    y='body_mass_g',\n",
    "    title='Horizontal Bar Chart (Bokeh)',\n",
    "    ylabel='Body Mass (g)',\n",
    "    xlabel='Species',\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fa6d4514-7dbd-486d-a1ff-8a732d097af6",
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas  # noqa\n",
    "hvplot.extension('matplotlib')\n",
    "\n",
    "df = hvplot.sampledata.penguins('pandas')\n",
    "grouped = df.groupby('species', observed=True)['body_mass_g'].mean()\n",
    "\n",
    "grouped.hvplot.barh(\n",
    "    x='species',\n",
    "    y='body_mass_g',\n",
    "    title='Horizontal Bar Chart (Matplotlib)',\n",
    "    ylabel='Body Mass (g)',\n",
    "    xlabel='Species',\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f289ba03-7d72-42ee-8621-e7f64f729e64",
   "metadata": {},
   "outputs": [],
   "source": [
    "grouped"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6335a800-d505-4fb6-a235-35c2acb62d9c",
   "metadata": {},
   "source": [
    ":::{seealso}\n",
    "- [Horizontal Bar Plots documentation](../../ref/api/manual/hvplot.hvPlot.barh.ipynb).\n",
    ":::"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
